<template>
  <div class="tl clearfix">
    <tableComponents :isShow="false" :isHaveAdd="false" :isHaveExport="false" :isHavePagination="false" :isCollection="isCode">
      <template v-slot:table>
        <el-row>
          <el-col :span="24">
            <el-col :span="8" class="span1 titl1">
              <span v-for="(title,i) in setlist(list)" v-show="$route.query.action" :key="i" class="size_13 s1" :class="{set_active:title.title== $store.state.title2}"
                @click="activeStyle(i,title)">{{title.title}}</span>
            </el-col>
          </el-col>
          <el-col :span="24" class="bg_write title2" v-loading="loading" style="z-index: 0;">
            <systemset :cate="$route.query.action" @sendAdmin="getUserObj"></systemset>
            <div v-show="!$route.query.action" class>sas</div>
          </el-col>
        </el-row>
      </template>
    </tableComponents>
  </div>
</template>
<script>
  import systemset from "./system_set.vue";
  import HeadTitle from "@/components/currency/HeadTitle.vue";
  import {
    mapState
  } from "vuex";
  export default {
    data() {
      return {
        cate: " ",
        index: 0,
        loading: false,
        z: "",
        list: "",
        menu: "",
        isCode: false//显示收款码
      };
    },
    methods: {
      activeStyle(index, list) {
        this.index = index;
        // this.$store.commit("setTitle2", list.title);
        this.$router.push(list.url);
      },
      getSanji(id) {
        var data = {
          id: id
        };
        this.$api.getMenu.selectMenu(data).then(res => {
          if (res.data.code == 200 && res.data.status == 1) {
            this.list = res.data.result;
          } else {
            this.$fnc.alertError(res.data.code_desc, "未知错误");
          }
        });
      },
      setlist(list) {
        var arr = [];
        list = list || [];
        for (var i = 0; i < list.length; i++) {
          if (list[i].url.lastIndexOf("action") > 0) {
            arr.push(list[i]);
          }
        }
        return arr;
      },
      getUserObj(obj) {
        this.$emit("send", obj);
      }
    },
    computed: {
      ...mapState({
        id: state => state.id
      })
    },
    components: {
      systemset,
      HeadTitle
    },
    watch: {
      id(val) {
        this.getSanji(val);
      }
    },
    beforeCreate() {
      this.loading = true;
    },
    created() {
      this.loading = false;
      
      //显示收款码
      let action = this.$route.query.action;
      if(action == "offlinepay"){
        this.isCode = true;
      }
    }
  };
</script>
<style lang="less" scoped>
</style>
